package com.spring.careclassapi.web.controller;



import java.util.HashMap;
import java.util.Map;

import javax.annotation.Resource;

import com.fasterxml.jackson.databind.util.JSONPObject;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.mangofactory.swagger.annotations.ApiIgnore;
import com.spring.careclassapi.web.service.CareClassApiService;
import com.spring.security.core.util.ApplicationUtils;
@Controller
@RequestMapping(value = "/careClassApi")
@ApiIgnore
public class CareClassApiController {
	
	@Resource
	private CareClassApiService careCourseApiService;
	

	//课程科目类型集合
	@RequestMapping(value = "/getCareClassTypeList")
	@ResponseBody
    public Object getCareClassTypeList(String callback) {
   
        Map<String, Object> m = new HashMap<String, Object>();
		try {

			m  = careCourseApiService.getCareClassTypeList();
					
		} catch (Exception e) {
			m.put(ApplicationUtils.STATUS, "0");
			m.put(ApplicationUtils.MSG, "系统异常");
			e.printStackTrace();

		}

    	
    	if(ApplicationUtils.isNotNull(callback)){
        	return new JSONPObject(callback, m);
        }else{
        	return m;
        }
        
        
    }
	//得到托班开课表
		@RequestMapping(value = "/getCareClassOpenList")
		@ResponseBody
	    public Object getCareClassOpenList(String care_class_type_id, String kids_park_id,
				String start_time, String end_time, String care_class_open_id, String page_size, 
				String page_index, String skip, String rows,String callback) {
	   
	        Map<String, Object> m = new HashMap<String, Object>();
			try {

				m  = careCourseApiService.getCareClassOpenList(care_class_type_id, kids_park_id, start_time, end_time, care_class_open_id, page_size, page_index, skip, rows);
						
			} catch (Exception e) {
				m.put(ApplicationUtils.STATUS, "0");
				m.put(ApplicationUtils.MSG, "系统异常");
				e.printStackTrace();

			}

	    	
	    	if(ApplicationUtils.isNotNull(callback)){
	        	return new JSONPObject(callback, m);
	        }else{
	        	return m;
	        }
	        
	        
	    }
		
		
		
		
		//得到托班开课表
		@RequestMapping(value = "/getMyCareCourseOpenList")
		@ResponseBody
	    public Object getMyCareCourseOpenList(String token,String c_user_id,String care_class_type_id, String kids_park_id,
				String start_time, String end_time, String care_class_open_id, String page_size, 
				String page_index, String skip, String rows,String callback) {
	   
	        Map<String, Object> m = new HashMap<String, Object>();
			try {

				m  = careCourseApiService.getMyCareCourseOpenList(token,c_user_id,care_class_type_id, kids_park_id, start_time, end_time, care_class_open_id, page_size, page_index, skip, rows);
						
			} catch (Exception e) {
				m.put(ApplicationUtils.STATUS, "0");
				m.put(ApplicationUtils.MSG, "系统异常");
				e.printStackTrace();

			}

	    	
	    	if(ApplicationUtils.isNotNull(callback)){
	        	return new JSONPObject(callback, m);
	        }else{
	        	return m;
	        }
	        
	        
	    }		

		//得到托班具体课程
		@RequestMapping(value = "/getCourseList")
		@ResponseBody
	 public Object getCourseList(String care_class_open_id,String callback) {
	
	     Map<String, Object> m = new HashMap<String, Object>();
			try {

				m  = careCourseApiService.getCourseList(care_class_open_id);
				
			} catch (Exception e) {
				m.put(ApplicationUtils.STATUS, "0");
				m.put(ApplicationUtils.MSG, "系统异常");
				e.printStackTrace();

			}

	 	
	 	if(ApplicationUtils.isNotNull(callback)){
	     	return new JSONPObject(callback, m);
	     }else{
	     	return m;
	     }
	     
	     
	 }
		
	// 预约托班
	@RequestMapping(value = "/appointCareClass")
	@ResponseBody
	public Object appointCareClass(String token,String c_user_id,String user_name,String care_class_open_id, String callback) {

		Map<String, Object> m = new HashMap<String, Object>();
		try {

			m = careCourseApiService.appointCareClass(token, c_user_id, user_name, care_class_open_id);

		} catch (Exception e) {
			m.put(ApplicationUtils.STATUS, "0");
			m.put(ApplicationUtils.MSG, "系统异常");
			e.printStackTrace();

		}

		if (ApplicationUtils.isNotNull(callback)) {
			return new JSONPObject(callback, m);
		} else {
			return m;
		}

	}
	
	
			
	// 预约托班
	@RequestMapping(value = "/cancelCareClass")
	@ResponseBody
	public Object cancelCareClass(String token,String c_user_id,String care_class_appointment_id, String callback) {

		Map<String, Object> m = new HashMap<String, Object>();
		try {

			m = careCourseApiService.cancelCareClass(token, c_user_id, care_class_appointment_id);

		} catch (Exception e) {
			m.put(ApplicationUtils.STATUS, "0");
			m.put(ApplicationUtils.MSG, "系统异常");
			e.printStackTrace();

		}

		if (ApplicationUtils.isNotNull(callback)) {
			return new JSONPObject(callback, m);
		} else {
			return m;
		}

	}		

	// 查看自己的预约/签到记录
	@RequestMapping(value = "/getMyCareClassList")
	@ResponseBody
	public Object getMyCareClassList(String token, String c_user_id,
			String isattended, String start_time, String end_time,
			String page_size, String page_index, String skip, String rows,
			String callback) {

		Map<String, Object> m = new HashMap<String, Object>();
		try {

			m = careCourseApiService.getMyCareClassList(token, c_user_id,
					isattended, start_time, end_time, page_size, page_index,
					skip, rows);

		} catch (Exception e) {
			m.put(ApplicationUtils.STATUS, "0");
			m.put(ApplicationUtils.MSG, "系统异常");
			e.printStackTrace();

		}

		if (ApplicationUtils.isNotNull(callback)) {
			return new JSONPObject(callback, m);
		} else {
			return m;
		}

	}
	

	
	@RequestMapping(value = "/getTodayCareClass")
	@ResponseBody
	public Object getTodayCareClass(String kids_parkID,String callback) {

		Map<String, Object> m = new HashMap<String, Object>();
		try {

			m = careCourseApiService.getTodayCareClass(kids_parkID);
		} catch (Exception e) {
			m.put(ApplicationUtils.STATUS, "0");
			m.put(ApplicationUtils.MSG, "系统异常");
			e.printStackTrace();

		}

		if (ApplicationUtils.isNotNull(callback)) {
			return new JSONPObject(callback, m);
		} else {
			return m;
		}

	}
	
}

